package com.yashi.springmvcjbpm.controller;

import javax.servlet.http.HttpServletRequest;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;



import com.opensymphony.xwork2.ActionSupport;
import com.yashi.springmvcjbpm.service.impl.LoginServiceImpl;


@Controller
public class LoginController extends ActionSupport{
	private String staffName;
	private String staffPsw;
	private LoginServiceImpl loginService = new LoginServiceImpl();
	
	@RequestMapping(value="/userLoginAction")
	public String loginIn(HttpServletRequest request){	
		staffName= request.getParameter("staffName");
		staffPsw= request.getParameter("staffPsw");
		System.out.println("name="+staffName+",pwd="+staffPsw);
		if(loginService.isLogin(staffName, staffPsw)){
			
			System.out.println("save user: "+staffName);
			String message = "";  				  					  
			request.getSession().setAttribute("mes", message); 
			request.getSession().setAttribute("staffName", staffName);
			return "index";
		}
			return "login";
		
	}
}
